﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
using System.Collections;

namespace RefOffPDA
{
    /*
     * Class: Match
     * 
     * Use: Used to model a Match object, and display details
     *      to the referee during the match
     *      
     * Author: Mike Skaife, mcs3@aber.ac.uk
     */ 
    public partial class Match : Form
    {
        //The id of the Match
        private int mMatch_id;

        //The number of substitutions during the match
        private int subOnCount;
        
        //Variables which make up the match timer
        public int tenMinutes = 0;
        public int minutes = 0;
        public int tenSeconds = 0;
        public int seconds = 0;

        //Details used to connect to database
        String conString;
        SqlCeConnection conn;

        //Incident screens
        public Incident homeIncident;
        public Incident awayIncident;

        //Caution screens
        public Caution homeCaution;
        public Caution awayCaution;

        //Caution Code screen
        public CautionCode cautionCode;

        //C1 Code screen
        public C1Code c1Code;


        //Sending Off screens
        public SendOff homeSendOff;
        public SendOff awaySendOff;

        //Sending Off Code screen
        public SendOffCode sendOffCode;

        //Goal screens
        public Goal homeGoal;
        public Goal awayGoal;
        
        //Substitution screens
        public SubOn homeSubOn;
        public SubOn awaySubOn;
        public SubOff homeSubOff;
        public SubOff awaySubOff;

        //End Match screen
        public EndMatch endMatch;

        //Extra Time screen
        public ExtraTime extraTime;

        //Object used for whistle detection
        public WhistleDetector whistleDetector;

        //Arrays of players on home and away team
        private List<Player> homePlayers;
        private List<Player> awayPlayers;

        //Arrays of buttons used on various screens, which
        //may need to be updated by a Caution, Sending
        //Off or Substitution
        private List<Button> homeGoalButtons;
        private List<Button> awayGoalButtons;
        private List<Button> homeCautionButtons;
        private List<Button> awayCautionButtons;
        private List<Button> homeSendOffButtons;
        private List<Button> awaySendOffButtons;
        private List<Button> homeSubOnButtons;
        private List<Button> awaySubOnButtons;
        private List<Button> homeSubOffButtons;
        private List<Button> awaySubOffButtons;

        //A new GPS object used to record location of device
        public GPS gpsReader;        

        //id of home and away club for use in database queries
        int home_club_id, away_club_id;

        //Indicates if the match timer is running
        public bool started = false;

        //Indicates if the match is in a period of extra time
        public bool isExtraTime = false;

        //Indicates whether a connection to the GPS antenna has
        //been established
        public bool gpsFound;
        
        //Create the new Match, involving the specified home and away team
        public Match(int home_id, int away_id)
        {
            InitializeComponent();
            
            //Initially there is no connection with the
            //GPS antenna
            gpsFound = false;

            //Try and connect to the GPS antenna
            try
            {
                //Default GPS port on Windows Mobile device is COM8
                gpsReader = new GPS("COM8");

                //Open the port and connect to antenna
                gpsReader.openPort();

                //Indicate that a connection has been established
                gpsFound = true;
            }
            catch
            {
                //If no connection could be established, inform the user
                MessageBox.Show("No GPS found. Please try again");                
            }
            
            //Set the text of the match timer to its initial value of '00:00'
            MatchTimerLLbl.Text = "" + tenMinutes + minutes + ":" + tenSeconds + seconds;

            // Retrieve the database connection string
            conString = @"Data Source=\Program Files\RefOffPDA\RefOffPDA_DB.sdf";

            //Set the initial details of the match
            mMatch_id = 1;
            subOnCount = 0;

            //Create Caution screen for each team
            homeCaution = new Caution(this, "home");
            awayCaution = new Caution(this, "away");

            //Create Caution Code and C1 Code screen for each team
            cautionCode = new CautionCode(this);
            c1Code = new C1Code(this);

            //Create Sending Off screen for each team
            homeSendOff = new SendOff(this, "home");
            awaySendOff = new SendOff(this, "away");

            //Create Sending Off code screen used by each time
            sendOffCode = new SendOffCode(this);

            //Create Incident screen for each team
            homeIncident = new Incident(this, "home");
            awayIncident = new Incident(this, "away");
            
            //Create Goal screen for each team
            homeGoal = new Goal(this, "home");
            awayGoal = new Goal(this, "away");

            //Create Substitution screens for each team
            homeSubOn = new SubOn(this);
            awaySubOn = new SubOn(this);
            homeSubOff = new SubOff(this, "home");
            awaySubOff = new SubOff(this, "away");

            //Create screens for use at end of Match
            endMatch = new EndMatch(this);
            extraTime = new ExtraTime(this);

            //Create new whistle detection object
            whistleDetector = new WhistleDetector();

            //Set id for each team in the Match
            home_club_id = home_id;
            away_club_id = away_id;

            //Create empty array to hold each teams players
            homePlayers = new List<Player>();
            awayPlayers = new List<Player>();

            //Create empty arrays to hold buttons
            homeGoalButtons = new List<Button>();
            awayGoalButtons = new List<Button>();
            homeCautionButtons = new List<Button>();
            awayCautionButtons = new List<Button>();
            homeSendOffButtons = new List<Button>();
            awaySendOffButtons = new List<Button>();
            homeSubOnButtons = new List<Button>();
            awaySubOnButtons = new List<Button>();
            homeSubOffButtons = new List<Button>();
            awaySubOffButtons = new List<Button>();

            //Fill the arrays with all Buttons from the various
            //screens so they can be referenced when they need
            //to be dynamically updated
            fillButtonArrays();

            //Set text on the buttons on the various screens with
            //details of the player they represent
            setHomePlayerNames();
            setAwayPlayerNames();

            //Tell the device to start listening for whistle events
            //startWhistleDetection();            
        }

        //This method is used to begin whistle detection
        private void startWhistleDetection()
        {
            //Start listening for whistles
            whistleDetector.begin();
        }

        //This method is used to stop whistle detection
        private void stopWhistleDetection()
        {
            //Stop listening for whistles
            whistleDetector.end();
        }

        //Add buttons to the relevant arrays to
        //allow manipulation during the Match
        private void fillButtonArrays()
        {
            //Get hold of Buttons from Goal screens
            fillGoalButtonArrays();
            //Get hold of Buttons from Caution screens
            fillCautionButtonArrays();
            //Get hold of Buttons from Sending Off screens
            fillSendOffButtonArrays();
            //Get hold of Buttons from Substitution screens
            fillSubOnButtonArrays();
            fillSubOffButtonArrays();
        }

        //Method used to set text on buttons relating to
        //the home team, at the start of the Match
        private void setHomePlayerNames()
        {            
            // Open the database connection using the connection string
            conn = new SqlCeConnection(conString);
            conn.Open();
            
            //Pull out Player data and stick it in a dataset
            string command = @"SELECT player_id, number, surname, on_pitch FROM player WHERE club_id = '" + home_club_id + "'"; 
            SqlCeDataAdapter da = new SqlCeDataAdapter(command, conn);
            DataSet ds = new DataSet();
            da.Fill(ds, "home_player_names");
            DataTable dt = ds.Tables["home_player_names"];

            //Find out how many players exist on the home team
            int numOfPlayers = ds.Tables[0].Rows.Count;

            //Create a new Player object
            Player newPlayer;

            //Loop through each player item in the dataset
            for (int i = 0; i < numOfPlayers; i++)
            {
                //Create the Player
                newPlayer = new Player();

                //Set the details of the Player from data in the dataset
                newPlayer.surname = (string)ds.Tables[0].Rows[i]["surname"];
                newPlayer.number = (int)ds.Tables[0].Rows[i]["number"];
                newPlayer.player_id = (int)ds.Tables[0].Rows[i]["player_id"];
                newPlayer.on_pitch = (int)ds.Tables[0].Rows[i]["on_pitch"];

                //Add player to the array representing the home squad
                homePlayers.Add(newPlayer);
            }              

            //Loop through all players in the home squad
            for (int i = 0; i < numOfPlayers; i++)
            {
                //If the player is in the starting line up...
                if (homePlayers[i].on_pitch == 1)
                {
                    //Set number and surname on all relevant buttons at start of match
                    homeGoalButtons[i].Text = homePlayers[i].number.ToString() + ". " + homePlayers[i].surname;
                    homeGoalButtons[i].Tag = homePlayers[i].player_id.ToString();
                    homeCautionButtons[i].Text = homePlayers[i].number.ToString() + ". " + homePlayers[i].surname;
                    homeCautionButtons[i].Tag = homePlayers[i].player_id.ToString();
                    homeSendOffButtons[i].Text = homePlayers[i].number.ToString() + ". " + homePlayers[i].surname;
                    homeSendOffButtons[i].Tag = homePlayers[i].player_id.ToString();
                    homeSubOffButtons[i].Text = homePlayers[i].number.ToString() + ". " + homePlayers[i].surname;
                    homeSubOffButtons[i].Tag = homePlayers[i].player_id.ToString();
                }
                //Otherwise the player is on the subs bench...
                else
                {
                    //Set text on Substitution screen buttons
                    homeSubOnButtons[subOnCount].Text = homePlayers[i].number.ToString() + ". " + homePlayers[i].surname;
                    homeSubOnButtons[subOnCount].Tag = homePlayers[i].player_id.ToString();
                    subOnCount++;
                }
            }

            //Within substitution screens, remove any blank buttons
            //depending on how many players are on the subs bench
            if (subOnCount < 10)
            {
                for(int i = subOnCount; i<11; i++)
                {
                    homeSubOnButtons[i].Visible = false;
                }

            }

            //Close database connection
            closeDatabaseConnection();
        }

        //Method used to set text on buttons relating to
        //the away team, at the start of the Match
        private void setAwayPlayerNames()
        {
            // Open the connection using the connection string
            conn = new SqlCeConnection(conString);
            conn.Open();

            //Pull out data and stick it in a dataset
            string command = @"SELECT player_id, number, surname, on_pitch FROM player WHERE club_id = '" + away_club_id + "'";
            SqlCeDataAdapter da = new SqlCeDataAdapter(command, conn);
            DataSet ds = new DataSet();
            da.Fill(ds, "away_player_names");
            DataTable dt = ds.Tables["away_player_names"];

            //Find out how many players exist on the away team
            int numOfPlayers = ds.Tables[0].Rows.Count;

            //Create a new Player object
            Player newPlayer;

            //Loop through each player item in the dataset
            for (int i = 0; i < numOfPlayers; i++)
            {
                //Create the Player
                newPlayer = new Player();

                //Set the details of the Player from data in the dataset
                newPlayer.surname = (string)ds.Tables[0].Rows[i]["surname"];
                newPlayer.number = (int)ds.Tables[0].Rows[i]["number"];
                newPlayer.player_id = (int)ds.Tables[0].Rows[i]["player_id"];
                newPlayer.on_pitch = (int)ds.Tables[0].Rows[i]["on_pitch"];

                //Add player to the array representing the away squad
                awayPlayers.Add(newPlayer);
            }

            //Indicate that no substitutions have occurred
            //at the start of the match
            int subOnCount = 0;
            
            //Loop through all players in the home squad
            for (int i = 0; i < numOfPlayers; i++)
            {
                //If the player is in the starting line up...
                if (awayPlayers[i].on_pitch == 1)
                {
                    //Set number and surname on all relevant buttons at start of match
                    awayGoalButtons[i].Text = awayPlayers[i].number.ToString() + ". " + awayPlayers[i].surname;
                    awayGoalButtons[i].Tag = awayPlayers[i].player_id.ToString();
                    awayCautionButtons[i].Text = awayPlayers[i].number.ToString() + ". " + awayPlayers[i].surname;
                    awayCautionButtons[i].Tag = awayPlayers[i].player_id.ToString();
                    awaySendOffButtons[i].Text = awayPlayers[i].number.ToString() + ". " + awayPlayers[i].surname;
                    awaySendOffButtons[i].Tag = awayPlayers[i].player_id.ToString();
                    awaySubOffButtons[i].Text = awayPlayers[i].number.ToString() + ". " + awayPlayers[i].surname;
                    awaySubOffButtons[i].Tag = awayPlayers[i].player_id.ToString();
                }
                //Otherwise the player is on the subs bench...
                else
                {
                    //Set text on Substitution screen buttons
                    awaySubOnButtons[subOnCount].Text = awayPlayers[i].number.ToString() + ". " + awayPlayers[i].surname;
                    awaySubOnButtons[subOnCount].Tag = awayPlayers[i].player_id.ToString();
                    subOnCount++;
                }
            }

            //Within substitution screens, remove any blank buttons
            //depending on how many players are on the subs bench
            if (subOnCount < 10)
            {
                for (int i = subOnCount; i < 11; i++)
                {
                    awaySubOnButtons[i].Visible = false;
                }

            }

            //Close database connection
            closeDatabaseConnection();
        }

        //This method runs every second during the match to update
        //the value of the timer on the screen
        private void MatchTimer_Tick(object sender, EventArgs e)
        {
            //Increase the number of seconds that have passed
            //during the match
            seconds++;

            //If the match is in a period of extra time...
            if (isExtraTime)
            {
                //If the timer reads '15:00'...
                if (tenMinutes == 1 && minutes == 5 && tenSeconds == 0 && seconds == 0)
                {
                    //Stop the timer as it is half time in extra time
                    MatchTimer.Enabled = false;
                    started = false;
                }
                //If the timer reads '30:00'
                else if (tenMinutes == 3 && minutes == 0 && tenSeconds == 0 && seconds == 0)
                {
                    //Stop the timer as it is full time in extra time
                    MatchTimer.Enabled = false;
                    started = false;
                }
                //Otherwise update the extra time timer
                //to reflect that another second has passed               
                else if (seconds == 10)
                {                    
                    tenSeconds++;
                    seconds = 0;
                    if (tenSeconds == 6)
                    {
                        minutes++;
                        tenSeconds = 0;
                        if (minutes == 10)
                        {
                            tenMinutes++;
                            minutes = 0;
                        }
                    }
                }
            }
            //This section of code runs if the match is not in
            //a period of extra time
            else
            {
                //If the timer reads '45:00'
                if (tenMinutes == 4 && minutes == 5 && tenSeconds == 0 && seconds == 0)
                {
                    //Stop the timer as it is half time
                    MatchTimer.Enabled = false;
                    started = false;
                }
                //If the timer reads '90:00'
                else if(tenMinutes == 9 && minutes == 0 && tenSeconds == 0 && seconds == 0)
                {
                    //Stop the timer as it is full time
                    MatchTimer.Enabled = false;
                    started = false;
                }
                //Otherwise update the timer to reflect the passing
                //of another second
                else if (seconds == 10)
                {
                    tenSeconds++;
                    seconds = 0;
                    if (tenSeconds == 6)
                    {
                        minutes++;
                        tenSeconds = 0;
                        if (minutes == 10)
                        {
                            tenMinutes++;
                            minutes = 0;
                        }
                    }
                }
            }      
      
            //Update the timer on the Match screen to reflect the passing of another second
            MatchTimerLLbl.Text = "" + tenMinutes + minutes + ":" + tenSeconds + seconds;
        }

        //This method runs when the user clicks on the match timer during a match
        private void MatchTimerLLbl_Click(object sender, EventArgs e)
        {
            //If the timer is currently stopped...
            if (started == false)
            {
                //Start the timer
                MatchTimer.Enabled = true;
                started = true;
            }
            //Otherwise if the timer is currently running...
            else
            {
                //Stop the timer
                MatchTimer.Enabled = false;
                started = false;
            }
        }

        //This method is called if the user chooses to show the End Match
        //screen, then cancels this action
        public void returnFromCancelEndMatch()
        {
            //Restart the match timer so
            //the match can continue
            MatchTimer.Enabled = true;
            started = true;            
        }

        //This method is called if the user clicks the 'End Match' button
        private void MatchExitMenuItem_Click(object sender, EventArgs e)
        {     
            //Stop the match timer
            MatchTimer.Enabled = false;
            started = false;

            //Display the End Match screen
            endMatch.Visible = true;  
        }

        //This method is called when the user clicks on the score for the
        //home team to indicate they have scored a goal
        private void MatchHomeScoreLLbl_Click(object sender, EventArgs e)
        {
            //Display the Goal screen
            homeGoal.Visible = true;
        }

        //This method is called when the user clicks on the score for the
        //away team to indicate they have scored a goal
        private void MatchAwayScoreLLbl_Click(object sender, EventArgs e)
        {
            //Display the Goal screen
            awayGoal.Visible = true;
        }

        //This method is called when the user clicks on the name
        //of the home team to indicate and incident has occurred
        private void MatchHomeTeamBtn_Click(object sender, EventArgs e)
        {
            //Display the Incident screen
            homeIncident.Visible = true;
        }

        //This method is called when the user clicks on the name
        //of the away team to indicate and incident has occurred
        private void MatchAwayTeamBtn_Click(object sender, EventArgs e)
        {
            //Display the Incident screen
            awayIncident.Visible = true;
        }

        //This method is used to disconnect from the database
        private void closeDatabaseConnection()
        {
            //Close the database connection
            conn.Close();
        }

        //This method is used to add all buttons from the Goal screen
        //for each team to the relevant array so they can be referenced
        //and updated dynamically during the match
        private void fillGoalButtonArrays()
        {
            homeGoalButtons.Add(homeGoal.GoalPlayer1Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer2Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer3Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer4Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer5Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer6Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer7Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer8Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer9Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer10Btn);
            homeGoalButtons.Add(homeGoal.GoalPlayer11Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer1Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer2Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer3Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer4Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer5Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer6Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer7Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer8Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer9Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer10Btn);
            awayGoalButtons.Add(awayGoal.GoalPlayer11Btn);
        }

        //This method is used to add all buttons from the Caution screen
        //for each team to the relevant array so they can be referenced
        //and updated dynamically during the match
        private void fillCautionButtonArrays()
        {
            homeCautionButtons.Add(homeCaution.CautionPlayer1Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer2Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer3Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer4Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer5Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer6Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer7Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer8Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer9Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer10Btn);
            homeCautionButtons.Add(homeCaution.CautionPlayer11Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer1Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer2Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer3Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer4Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer5Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer6Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer7Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer8Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer9Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer10Btn);
            awayCautionButtons.Add(awayCaution.CautionPlayer11Btn);
        }

        //This method is used to add all buttons from the Sending Off screen
        //for each team to the relevant array so they can be referenced
        //and updated dynamically during the match
        private void fillSendOffButtonArrays()
        {
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer1Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer2Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer3Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer4Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer5Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer6Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer7Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer8Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer9Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer10Btn);
            homeSendOffButtons.Add(homeSendOff.SendOffPlayer11Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer1Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer2Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer3Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer4Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer5Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer6Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer7Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer8Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer9Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer10Btn);
            awaySendOffButtons.Add(awaySendOff.SendOffPlayer11Btn);
        }

        //This method is used to add all buttons from the Substitution On screen
        //for each team to the relevant array so they can be referenced
        //and updated dynamically during the match
        private void fillSubOnButtonArrays()
        {
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer1Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer3Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer5Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer7Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer9Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer11Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer2Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer4Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer6Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer8Btn);
            homeSubOnButtons.Add(homeSubOn.SubOnPlayer10Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer1Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer3Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer5Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer7Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer9Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer11Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer2Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer4Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer6Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer8Btn);
            awaySubOnButtons.Add(awaySubOn.SubOnPlayer10Btn);
        }

        //This method is used to add all buttons from the Substitution Off screen
        //for each team to the relevant array so they can be referenced
        //and updated dynamically during the match
        private void fillSubOffButtonArrays()
        {
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer1Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer2Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer3Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer4Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer5Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer6Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer7Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer8Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer9Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer10Btn);
            homeSubOffButtons.Add(homeSubOff.SubOffPlayer11Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer1Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer2Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer3Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer4Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer5Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer6Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer7Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer8Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer9Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer10Btn);
            awaySubOffButtons.Add(awaySubOff.SubOffPlayer11Btn);
        }

        //This method allows other classes to obtain the id of this Match
        public int match_id
        {
            get
            {
                return mMatch_id;
            }
        }
    }
}